clc;clear
horse_data = xlsread('E:\马的心电图特征提取\new_data.xlsx','sheet1');   %读取滤波后的数据
%% 存储每匹马的数据
horse_1 = xlsread('E:\马的心电图特征提取\new_data.xlsx','sheet1','CI1:ET1');  %1号马部分数据
horse_2 = xlsread('E:\马的心电图特征提取\new_data.xlsx','sheet1','CB2:EK2');  %2号马部分数据
horse_3 = xlsread('E:\马的心电图特征提取\new_data.xlsx','sheet1','CB3:EF3');  %3号马部分数据
horse_4 = xlsread('E:\马的心电图特征提取\new_data.xlsx','sheet1','AN4:CV4');  %4号马部分数据
horse_5 = xlsread('E:\马的心电图特征提取\new_data.xlsx','sheet1','DP5:FT5');  %5号马部分数据
horse_6 = xlsread('E:\马的心电图特征提取\new_data.xlsx','sheet1','FD6:HH6');  %6号马部分数据
horse_7 = xlsread('E:\马的心电图特征提取\new_data.xlsx','sheet1','CK7:EV7');  %7号马部分数据
horse_8 = xlsread('E:\马的心电图特征提取\new_data.xlsx','sheet1','AV8:DF8');  %8号马部分数据
horse_9 = xlsread('E:\马的心电图特征提取\new_data.xlsx','sheet1','EG9:GQ9');  %9号马部分数据
%% 绘图
figure(1)
x1 = 1:1:64;     %第1匹马
subplot(2,2,1)
plot(x1,horse_1,'LineWidth',1.5);axis ([0 64 0 123]);

max1 = max(horse_1);  %最大值提取
[pks1,locs1] = findpeaks(horse_1);  %获取峰值及对应位置
n_horse_1 = max1-horse_1;      %波形翻转
[n_ks1,n_locs1] = findpeaks(n_horse_1);
hold on
plot(locs1,pks1,'ro',n_locs1,max1-n_ks1,'go','LineWidth',1.5);   %标记极大值、极小值点

title('filter-horse1-ECG');xlabel('t/ms');ylabel('mV'); 
set(gca,'FontName','Times New Roman','FontSize',14,'FontWeight','bold','FontAngle','italic','linewidth',2 );	%设置坐标刻度字体
%% 
x2 = 1:1:62;   %第2匹马
subplot(2,2,2)
plot(x2,horse_2,'LineWidth',1.5);axis ([0 62 0 123]);

max2 = max(horse_2);  %最大值提取
[pks2,locs2] = findpeaks(horse_2);  %获取峰值及对应位置
n_horse_2 = max2-horse_2;      %波形翻转
[n_ks2,n_locs2] = findpeaks(n_horse_2);
hold on
plot(locs2,pks2,'ro',n_locs2,max2-n_ks2,'go','LineWidth',1.5);   %标记极大值、极小值点

title('filter-horse2-ECG');xlabel('t/ms'); ylabel('mV'); 
set(gca,'FontName','Times New Roman','FontSize',14,'FontWeight','bold','FontAngle','italic','linewidth',2 );
%%
x3 = 1:1:57;   %第3匹马
subplot(2,2,3)
plot(x3,horse_3,'LineWidth',1.5);axis ([0 57 0 123]);

max3 = max(horse_3);  %最大值提取
[pks3,locs3] = findpeaks(horse_3);  %获取峰值及对应位置
n_horse_3 = max3-horse_3;      %波形翻转
[n_ks3,n_locs3] = findpeaks(n_horse_3);
hold on
plot(locs3,pks3,'ro',n_locs3,max3-n_ks3,'go','LineWidth',1.5);   %标记极大值、极小值点

title('filter-horse3-ECG');xlabel('t/ms'); ylabel('mV'); 
set(gca,'FontName','Times New Roman','FontSize',14,'FontWeight','bold','FontAngle','italic','linewidth',2 );
%%
x4 = 1:1:61;   %第4匹马
subplot(2,2,4)
plot(x4,horse_4,'LineWidth',1.5);axis ([0 61 0 123]);

max4 = max(horse_4);  %最大值提取
[pks4,locs4] = findpeaks(horse_4);  %获取峰值及对应位置
n_horse_4 = max4-horse_4;      %波形翻转
[n_ks4,n_locs4] = findpeaks(n_horse_4);
hold on
plot(locs4,pks4,'ro',n_locs4,max4-n_ks4,'go','LineWidth',1.5);   %标记极大值、极小值点

title('filter-horse4-ECG');xlabel('t/ms'); ylabel('mV'); 
set(gca,'FontName','Times New Roman','FontSize',14,'FontWeight','bold','FontAngle','italic','linewidth',2 );
%%
figure(2)
x5 = 1:1:57;   %第5匹马
subplot(2,2,1)
plot(x5,horse_5,'LineWidth',1.5);axis ([0 57 0 123]);

max5 = max(horse_5);  %最大值提取
[pks5,locs5] = findpeaks(horse_5);  %获取峰值及对应位置
n_horse_5 = max5-horse_5;      %波形翻转
[n_ks5,n_locs5] = findpeaks(n_horse_5);
hold on
plot(locs5,pks5,'ro',n_locs5,max5-n_ks5,'go','LineWidth',1.5);   %标记极大值、极小值点

title('filter-horse5-ECG');xlabel('t/ms'); ylabel('mV'); 
set(gca,'FontName','Times New Roman','FontSize',14,'FontWeight','bold','FontAngle','italic','linewidth',2 );
%%
x6 = 1:1:57;   %第6匹马
subplot(2,2,2)
plot(x6,horse_6,'LineWidth',1.5);axis ([0 57 0 123]);

max6 = max(horse_6);  %最大值提取
[pks6,locs6] = findpeaks(horse_6);  %获取峰值及对应位置
n_horse_6 = max6-horse_6;      %波形翻转
[n_ks6,n_locs6] = findpeaks(n_horse_6);
hold on
plot(locs6,pks6,'ro',n_locs6,max6-n_ks6,'go','LineWidth',1.5);   %标记极大值、极小值点

title('filter-horse6-ECG');xlabel('t/ms'); ylabel('mV'); 
set(gca,'FontName','Times New Roman','FontSize',14,'FontWeight','bold','FontAngle','italic','linewidth',2 );
%%
x7 = 1:1:64;   %第7匹马
subplot(2,2,3)
plot(x7,horse_7,'LineWidth',1.5);axis ([0 64 0 123]);

max7 = max(horse_7);  %最大值提取
[pks7,locs7] = findpeaks(horse_7);  %获取峰值及对应位置
n_horse_7 = max7-horse_7;      %波形翻转
[n_ks7,n_locs7] = findpeaks(n_horse_7);
hold on
plot(locs7,pks7,'ro',n_locs7,max7-n_ks7,'go','LineWidth',1.5);   %标记极大值、极小值点

title('filter-horse7-ECG');xlabel('t/ms'); ylabel('mV'); 
set(gca,'FontName','Times New Roman','FontSize',14,'FontWeight','bold','FontAngle','italic','linewidth',2 );
%%
x8 = 1:1:63;   %第8匹马
subplot(2,2,4)
plot(x8,horse_8,'LineWidth',1.5);axis ([0 63 0 123]);

max8 = max(horse_8);  %最大值提取
[pks8,locs8] = findpeaks(horse_8);  %获取峰值及对应位置
n_horse_8 = max8-horse_8;      %波形翻转
[n_ks8,n_locs8] = findpeaks(n_horse_8);
hold on
plot(locs8,pks8,'ro',n_locs8,max8-n_ks8,'go','LineWidth',1.5);   %标记极大值、极小值点

title('filter-horse8-ECG');xlabel('t/ms'); ylabel('mV'); 
set(gca,'FontName','Times New Roman','FontSize',14,'FontWeight','bold','FontAngle','italic','linewidth',2 );
%%
figure(3)  %第9匹马
x9 = 1:1:63; 
plot(x9,horse_9,'LineWidth',1.5);axis ([0 63 0 123]);

max9 = max(horse_9);  %最大值提取
[pks9,locs9] = findpeaks(horse_9);  %获取峰值及对应位置
n_horse_9 = max9-horse_9;      %波形翻转
[n_ks9,n_locs9] = findpeaks(n_horse_9);
hold on
plot(locs9,pks9,'ro',n_locs9,max9-n_ks9,'go','LineWidth',1.5);   %标记极大值、极小值点

title('filter-horse9-ECG');xlabel('t/ms'); ylabel('mV'); 
set(gca,'FontName','Times New Roman','FontSize',14,'FontWeight','bold','FontAngle','italic','linewidth',2 );